<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="templates2/layout.xhtml">
	<ui:define name="header">
		<ui:include src="templates2/header.xhtml">
			<ui:param name="current" value="Saving Account Detail"></ui:param>
			<ui:param name="title" value="Saving Account Management"></ui:param>
		</ui:include>
	</ui:define>
	<ui:define name="content">
		<h:form>
			<c:if test="${not empty savingAccDetailManagedBean.message}">
				<h4 class="alert_info">#{savingAccDetailManagedBean.message}</h4>
			</c:if>
			<article class="module width_full">
				<header>
					<h3>Account owner information</h3>
				</header>
				<div class="module_content">
					<fieldset style="width: 48%; float: left; margin-right: 3%;">
						<label>Customer ID</label>#{savingAccDetailManagedBean.customer.customerID}
					</fieldset>
					<fieldset style="width: 48%; float: left;">
						<label>ID Card Number</label>#{savingAccDetailManagedBean.customer.idCardNumber}
					</fieldset>
					<fieldset style="width: 32%; float: left; margin-right: 1.5%;">
						<label>First name</label>#{savingAccDetailManagedBean.customer.firstName}
					</fieldset>
					<fieldset style="width: 32%; float: left; margin-right: 1.5%;">
						<label>Middle name</label>#{savingAccDetailManagedBean.customer.midName}
					</fieldset>
					<fieldset style="width: 32%; float: left;">
						<label>Last name</label>#{savingAccDetailManagedBean.customer.lastName}
					</fieldset>
					<fieldset style="width: 48%; float: left; margin-right: 3%;">
						<label>Address 1</label>#{savingAccDetailManagedBean.customer.address}
					</fieldset>
					<fieldset style="width: 48%; float: left;">
						<label>Address 2</label>#{savingAccDetailManagedBean.customer.address2}
					</fieldset>
					<fieldset style="width: 48%; float: left; margin-right: 3%;">
						<label>Email 1</label>#{savingAccDetailManagedBean.customer.email}
					</fieldset>
					<fieldset style="width: 48%; float: left;">
						<label>Email 2</label>#{savingAccDetailManagedBean.customer.email2}
					</fieldset>
					<fieldset style="width: 48%; float: left; margin-right: 3%;">
						<label>Phone 1</label>#{savingAccDetailManagedBean.customer.phoneNumber}
					</fieldset>
					<fieldset style="width: 48%; float: left;">
						<label>Phone 2</label>#{savingAccDetailManagedBean.customer.phoneNumber2}
					</fieldset>
					<div class="clear"></div>
				</div>
			</article>
			<c:if test="${not empty savingAccDetailManagedBean.savingBook}">
				<article class="module width_full">
					<header>
						<h3>Saving book</h3>
					</header>
					<div class="module_content">
						<fieldset style="width: 100%;">
							<div class="tab_container">
								<div id="tab1" class="tab_content" style="display: block;">
									<h:dataTable styleClass="tablesorter"
										value="#{savingAccDetailManagedBean.savingBook}" var="s">
										<h:column>
											<f:facet name="header"></f:facet>
										</h:column>
										<h:column>
											<f:facet name="header">Account Number
								</f:facet>
								#{s.accountNumber}
							</h:column>
										<h:column>
											<f:facet name="header">From Date</f:facet>
								#{s.fromDate}
							</h:column>
										<h:column>
											<f:facet name="header">To Date</f:facet>
								#{s.toDate}
							</h:column>
										<h:column>
											<f:facet name="header">Interest Rate</f:facet>
								#{s.interestRate.rate}
							</h:column>
										<h:column>
											<f:facet name="header">Balance</f:facet>
								#{s.balance}
							</h:column>
									</h:dataTable>

								</div>
							</div>
						</fieldset>
						<div class="clear"></div>
					</div>
				</article>
			</c:if>
			<article class="module width_full">
				<header>
					<h3>Saving Account information</h3>
				</header>
				<div class="module_content">
					<fieldset style="width: 48%; float: left; margin-right: 3%;">
						<label>Saving Account Number</label>#{savingAccDetailManagedBean.customerAccount.accountNumber}
					</fieldset>
					<fieldset style="width: 48%; float: left;">
						<label>Current Balance</label>#{savingAccDetailManagedBean.customerAccount.accountBalance}
					</fieldset>
					<fieldset style="width: 32%; float: left; margin-right: 1.5%;">
						<label>Repeatable</label>
						<c:choose>
							<c:when
								test="${savingAccDetailManagedBean.customerAccount.repeatable}">
								Yes
							</c:when>
							<c:otherwise>
								No
							</c:otherwise>
						</c:choose>
					</fieldset>
					<fieldset style="width: 32%; float: left; margin-right: 1.5%;">
						<label>Created Date </label>
						#{savingAccDetailManagedBean.customerAccount.createdDate}
					</fieldset>
					<fieldset style="width: 32%; float: left;">
						<label>Account State</label>#{savingAccDetailManagedBean.customerAccount.accountState}
					</fieldset>
					<div class="clear"></div>
				</div>
			</article>
			
				<article class="module width_full">
					<header>
						<h3 class="tabs_involved">Transaction Details</h3>
						<div class="submit_link">
							<c:if test="${savingAccManagedBean.admin}">
								<h:commandButton value="Deny"
									action="#{savingAccDetailManagedBean.deny}" />
								<h:commandButton value="Approve"
									action="#{savingAccDetailManagedBean.approve}" />
							</c:if>
							<c:if test="${savingAccManagedBean.support}">
								<h:commandButton value="Create New"
									action="CreateTransaction?faces-redirect=true" />
							</c:if>
							<h:commandButton type="submit"
								action="saving-acc-mng?faces-redirect=true" value="Back" />
						</div>
					</header>
					<c:if test="${not empty savingAccDetailManagedBean.txs}">
					<div class="module_content">
						<fieldset style="width: 100%;">
							<p:dataTable paginator="true" rows="5"
								value="#{savingAccDetailManagedBean.txs}" var="t">
								<p:column>
									<f:facet name="header"></f:facet>
									<h:selectBooleanCheckbox
										value="#{savingAccDetailManagedBean.checked[t.transactionID]}"
										rendered="${t.transactionState == 'HOLD' and savingAccManagedBean.admin}"></h:selectBooleanCheckbox>
								</p:column>
								<p:column>
									<f:facet name="header">Transaction ID
								</f:facet>
								#{t.transactionID}
							</p:column>
								<p:column>
									<f:facet name="header">Fund</f:facet>
								#{t.funds}
							</p:column>
								<p:column>
									<f:facet name="header">Created Date</f:facet>
									<h:outputText value="#{t.createdDate}">
									<f:convertDateTime pattern="hh:mm:ss dd-MM-yy"></f:convertDateTime>
								</h:outputText>
								
							</p:column>
								<p:column>
									<f:facet name="header">Begin Time</f:facet>
								<h:outputText value="#{t.beginTime}">
									<f:convertDateTime pattern="hh:mm:ss dd-MM-yy"></f:convertDateTime>
								</h:outputText>
							</p:column>
								<p:column>
									<f:facet name="header">End Time</f:facet>
								<h:outputText value="#{t.endTime}">
									<f:convertDateTime pattern="hh:mm:ss dd-MM-yy"></f:convertDateTime>
								</h:outputText>
							</p:column>
								<p:column>
									<f:facet name="header">State</f:facet>
								#{t.transactionState}
								</p:column>
								<p:column>
									<f:facet name="header">Action</f:facet>
									<h:commandButton value="Deny"
										rendered="${t.transactionState == 'HOLD' and savingAccManagedBean.admin}" action="#{savingAccDetailManagedBean.denyTx}">
										<f:setPropertyActionListener
											target="#{savingAccDetailManagedBean.selectedTx}"
											value="#{t}" />
									</h:commandButton>
									<h:commandButton value="Approve"
										rendered="${t.transactionState == 'HOLD' and savingAccManagedBean.admin}" action="#{savingAccDetailManagedBean.approveTx}">
										<f:setPropertyActionListener
											target="#{savingAccDetailManagedBean.selectedTx}"
											value="#{t}" />
									</h:commandButton>
								</p:column>
							</p:dataTable>
						</fieldset>
					</div>
					</c:if>
					<footer>
						<div class="submit_link">
							From
							<p:calendar id="from" value="#{savingAccDetailManagedBean.from}"
								mode="popup"></p:calendar>
							To
							<p:calendar id="to" value="#{savingAccDetailManagedBean.to}"
								mode="popup"></p:calendar>
							<h:commandButton action="#{savingAccDetailManagedBean.search}"
								value="Search" />
						</div>
					</footer>
					
					<!-- end of .tab_container -->
				</article>
			
		</h:form>
	</ui:define>
	<ui:define name="sidebar">
		<ui:include src="templates2/sidebar.xhtml" />
	</ui:define>
</ui:composition>
</html>